/**
 * 
 */
package com.agilegroup.crm.requests;

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;

import com.agilegroup.crm.model.Contact;
import com.octo.android.robospice.request.springandroid.SpringAndroidSpiceRequest;

/**
 * @author Hisham
 *
 */
public class PostContactJsonRequest extends SpringAndroidSpiceRequest<Contact>{

	private String url;
	private Contact contact;
	
	public PostContactJsonRequest(Contact contact,String url) {
		super(Contact.class);
		this.contact=contact;
		this.url=url;
	}
	
	@Override
	public Contact loadDataFromNetwork() throws Exception { 
		
		HttpHeaders httpHeaders = new HttpHeaders();
        httpHeaders.setContentType(MediaType.APPLICATION_JSON);
        HttpEntity<Contact>httpEntity = new HttpEntity<Contact>(contact,httpHeaders);
        return getRestTemplate().postForObject(url, httpEntity, Contact.class);	
	}
}
